//
//  TTConfirmSuccessHintView.m
//  TaoTuo
//
//  Created by admin on 2020/3/22.
//  Copyright © 2020 admin. All rights reserved.
//

#import "TTConfirmSuccessHintView.h"
#import <UIView+TYAlertView.h>
#import "TTMessageViewController.h"
#import "TTMyOrderViewController.h"

@interface TTConfirmSuccessHintView ()

@property (weak, nonatomic) IBOutlet UIView *bgView;

@end

@implementation TTConfirmSuccessHintView

- (void)awakeFromNib
{
    [super awakeFromNib];
    
    _bgView.layer.cornerRadius = 10;
    _bgView.layer.shadowColor = UIColorHex(090909).CGColor;
    _bgView.layer.shadowOpacity = 0.2;
    _bgView.layer.shadowOffset = CGSizeZero;
    
}

- (IBAction)tuoClick:(id)sender {
    
    [self hideInWindow];
    
    UITabBarController *rootVC = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
    // 如果已经有控制器被弹出了，找到最上层的控制器
    UIViewController *topVC = rootVC.presentedViewController;
    while (topVC.presentedViewController) {
        topVC = topVC.presentedViewController;
    }
    if (topVC) {
        [topVC dismissViewControllerAnimated:YES completion:nil];
    }
    
    [[LLRouteTool getCurrentNavigationController] popToRootViewControllerAnimated:YES];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        TTMessageViewController *messageVC = [[TTMessageViewController alloc] init];
        messageVC.defaultSelectIndex = 0;
        messageVC.isPresent = YES;
        LLNavigationViewController *nav = [[LLNavigationViewController alloc] initWithRootViewController:messageVC];
        nav.modalPresentationStyle = UIModalPresentationFullScreen;
        [rootVC presentViewController:nav animated:NO completion:nil];
        [rootVC setSelectedIndex:0];
        
    });
    
}


- (IBAction)zuanClick:(id)sender {


    [self hideInWindow];
    
    UITabBarController *rootVC = (UITabBarController *)[UIApplication sharedApplication].keyWindow.rootViewController;
    // 如果已经有控制器被弹出了，找到最上层的控制器
    UIViewController *topVC = rootVC.presentedViewController;
    while (topVC.presentedViewController) {
        topVC = topVC.presentedViewController;
    }
    if (topVC) {
        [topVC dismissViewControllerAnimated:YES completion:nil];
    }
    
    [[LLRouteTool getCurrentNavigationController] popToRootViewControllerAnimated:YES];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        
        TTMessageViewController *messageVC = [[TTMessageViewController alloc] init];
        messageVC.defaultSelectIndex = 1;
        messageVC.isPresent = YES;
        LLNavigationViewController *nav = [[LLNavigationViewController alloc] initWithRootViewController:messageVC];
        nav.modalPresentationStyle = UIModalPresentationFullScreen;
        [rootVC presentViewController:nav animated:NO completion:nil];
        [rootVC setSelectedIndex:0];
        
    });
    
}



- (IBAction)gotoMainPage:(id)sender {

    [self hideInWindow];

    TTMyOrderViewController *orderVC = [[TTMyOrderViewController alloc] init];
    [[LLRouteTool getCurrentNavigationController] pushViewController:orderVC animated:YES];
}

@end
